package com.hdd.hll.quartz.job;

import lombok.SneakyThrows;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Map;
import java.util.Set;

@Component
public class TestJob implements Job {
    @SneakyThrows
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        System.out.println(LocalDateTime.now() + "我被执行了" + context.getScheduler().getSchedulerInstanceId());
        Map map = context.getJobDetail().getJobDataMap();
        Set<Map.Entry<String, String>> entrys = map.entrySet();
        for (Map.Entry<String, String> entry : entrys) {
            // 渠道参数，执行相应的业务流程
            System.out.println("流程执行：" + entry.getKey() + "--->>>" + entry.getValue());
            context.getScheduler().deleteJob(JobKey.jobKey(entry.getKey()));
        }
    }
}
